//
//  MyAttentionViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/22.
//

@interface AttentionTableCell : UITableViewCell

@property(nonatomic,strong) MyLinearLayout *root;
@end

@implementation AttentionTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if(self == [super initWithStyle: style reuseIdentifier:reuseIdentifier]){
        self.backgroundColor = COLOR_5;
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        
        MyLinearLayout *root = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
        root.myWidth = kScreenWidth;
        root.paddingTop = 15;
        root.cacheEstimatedRect = YES;
        root.heightSize.equalTo(root.heightSize).min(70);
        [self.contentView addSubview:root];
        self.root = root;
        
        MyLinearLayout *backView = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
        backView.backgroundColor = COLOR_4;
        ViewCorner(backView, 15);
        backView.myHorzMargin = 15;
        backView.myHeight = kAutoHeight;
        backView.padding = UIEdgeInsetsMake(10, 10, 10, 10);
        backView.subviewVSpace = 10;
        [root addSubview:backView];

        MyLinearLayout *top = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        top.myHorzMargin = 1;
        top.myHeight = kAutoHeight;
        top.gravity = MyGravity_Vert_Center;
        top.subviewHSpace = 5;
        [backView addSubview:top];

        {
            UILabel *name = [UILabel createLabelText:@"周晓咏" font:UIFontBoldMake(14) textColor:COLOR1515];
            name.mySize = kAutoSize;
            [top addSubview:name];
            
            UIImageView *sex = [[UIImageView alloc]initWithImage:UIImageMake(@"profile_nv")];
            sex.mySize = CGSizeMake(16, 16);
            [top addSubview:sex];
            
            [top addSubview:[self addWeightView]];
            
            UIButton *btn = [UIButton createButtonText:@"已关注" font:UIFontMake(13) textColor:HexColor(@"#BABABA")];
            btn.mySize = CGSizeMake(63, 28);
            ViewCorner(btn, 14);
            btn.backgroundColor = HexColor(@"#F3F3F3");
            [top addSubview:btn];
        }
        
        UILabel *height = UILabel.new;
        height.mySize = kAutoSize;
        height.attributedText = AttributedString(@"• 出生日期：", UIFontMake(14), COLOR999, @"1985-09-20", UIFontMake(14), COLOR1515, NSTextAlignmentLeft, 3);
        [backView addSubview:height];
        
        UILabel *Height = UILabel.new;
        Height.mySize = kAutoSize;
        Height.attributedText = AttributedString(@"• 身高：", UIFontMake(14), COLOR999, @"150cm", UIFontMake(14), COLOR1515, NSTextAlignmentLeft, 3);
        [backView addSubview:Height];
        
        UILabel *weight = UILabel.new;
        weight.mySize = kAutoSize;
        weight.attributedText = AttributedString(@"• 体重：", UIFontMake(14), COLOR999, @"55kg", UIFontMake(14), COLOR1515, NSTextAlignmentLeft, 3);
        [backView addSubview:weight];
        
        UILabel *phone = UILabel.new;
        phone.mySize = kAutoSize;
        phone.attributedText = AttributedString(@"• 联系方式：", UIFontMake(14), COLOR999, @"156456456", UIFontMake(14), COLOR1515, NSTextAlignmentLeft, 3);
        [backView addSubview:phone];
        
        UIView *line = UIView.new;
        line.myHorzMargin = 0;
        line.myHeight = 0.5;
        line.backgroundColor = HexColor(@"#E3E3E3");
        [backView addSubview:line];
        
        MyLinearLayout *bottom = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        bottom.myHorzMargin = 0;
        bottom.myHeight = 30;
        bottom.gravity = MyGravity_Horz_Center | MyGravity_Vert_Center;
        [backView addSubview:bottom];
        
        {
            UIImageView *sex = [[UIImageView alloc]initWithImage:UIImageMake(@"profile_report_logo")];
            sex.mySize = CGSizeMake(18, 18);
            [bottom addSubview:sex];
            
            UILabel *name = [UILabel createLabelText:@"TA的健康报告" font:UIFontMake(14) textColor:COLOR1515];
            name.mySize = kAutoSize;
            [bottom addSubview:name];
            
            UIImageView *right = [[UIImageView alloc]initWithImage:UIImageMake(@"icon_arrow_right")];
            right.mySize = CGSizeMake(16, 16);
            [bottom addSubview:right];
            
        }
        
    }
    return self;
}

- (UIView *)addWeightView {
    UIView *view = [UIView new];
    view.weight = 1;;
    return view;
}

- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSize withHorizontalFittingPriority:(UILayoutPriority)horizontalFittingPriority verticalFittingPriority:(UILayoutPriority)verticalFittingPriority
{
    if (@available(iOS 11.0, *)) {
       return [self.root sizeThatFits:CGSizeMake(targetSize.width - self.safeAreaInsets.left - self.safeAreaInsets.right, targetSize.height)];
    } else {
        return [self.root sizeThatFits:targetSize];
    }
}

@end

#import "MyAttentionViewController.h"

@interface MyAttentionViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong) UITableView *tableView;
@end

@implementation MyAttentionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = BACKGROUNDCOLOR;
    self.title = @"我的关注";
}

- (void)initSubviews {
    [super initSubviews];
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, NavigationContentTop, kScreenWidth, kScreenHeight - NavigationContentTop)];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.backgroundColor = COLOR_5;
    [self.tableView registerClass:[AttentionTableCell class] forCellReuseIdentifier:@"AttentionTableCell"];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = false;
    self.tableView.bounces = false;
    [self.view addSubview:self.tableView];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    AttentionTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AttentionTableCell" forIndexPath:indexPath];
    
    
    
    return  cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
